

#include <cstddef>
#include <libavutil/error.h>
#include <string>
#include <iostream>
#include <cstdio>
#include <cstdlib>

extern "C" {

    #include <libavformat/avformat.h>
    #include <libavutil/avutil.h>
    #include <libavcodec/codec.h>
    #include <libavutil/error.h>
}



int main(int argc, char * argv[]) {

    const std::string input_file = "";
    const std::string output_file = "/home/hjie/source/open_net/ffmpeg/trans/build/output.h264";

    AVFormatContext * input = NULL;
    AVFormatContext * output = NULL;

    int result = avformat_open_input(&input, input_file.c_str(), NULL, NULL);

    if (result < 0) {

        std::cout << "Error: avformat_open_input : " << result << std::endl;
        return EXIT_FAILURE;
    }
    avformat_find_stream_info(input, NULL);
    av_dump_format(input, 0, input_file.c_str(), 0);

    result = avformat_alloc_output_context2(&output, NULL, "h264", output_file.c_str());
    if (result < 0) {

        std::cout << "Error: avformat_alloc_output_context2 : " << result << std::endl;
        return EXIT_FAILURE;
    }
    
    return EXIT_SUCCESS;
}   